class AddPublishedToDirectories < ActiveRecord::Migration
  def change
    add_column :directories, :published, :boolean, default: true
    if column_exists? :users, :forem_admin
        rename_column :users, :forem_admin, :admin 
    elsif !column_exists?(:users, :admin)
        add_column :users, :admin, :boolean, default: false 
    end

    remove_column :users, :forem_state if column_exists? :users, :forem_state

    remove_column :users, :forem_auto_subscribe if column_exists? :users, :forem_auto_subscribe

    drop_table :forem_categories if ActiveRecord::Base.connection.table_exists? 'forem_categories'
    drop_table :forem_forums if ActiveRecord::Base.connection.table_exists? 'forem_forums'
    drop_table :forem_groups if ActiveRecord::Base.connection.table_exists? 'forem_groups'
    drop_table :forem_memberships if ActiveRecord::Base.connection.table_exists? 'forem_memberships'
    drop_table :forem_posts if ActiveRecord::Base.connection.table_exists? 'forem_posts'
    drop_table :forem_views if ActiveRecord::Base.connection.table_exists? 'forem_views'
    drop_table :forem_subscriptions if ActiveRecord::Base.connection.table_exists? 'forem_subscriptions'
  end
end
